<?php

namespace api\modules\ua\models;

use Yii;
use yii\db\ActiveRecord;
use yii\data\ActiveDataProvider;
use yii\db\Exception;
use Datetime;

class Online extends ActiveRecord
{
    public static function getDb(){return Yii::$app->ua;}
    public static function tableName(){return 'shops_online';}

    public function fields()
    {
        $fields = parent::fields();
        return $fields;
    }

    //创建
    public function create($uuid, $status, $count, $dateTime)
    {
        $this->uuid        = $uuid;
        $this->online      = $status;
        $this->count       = $count;
        $this->event_date  = $dateTime['date'];
        $this->event_time  = $dateTime['time'];
        $this->save();
    }


    //扩展字段
    public function getRef()
    {
        return $this->hasOne(UserInfo::className(), ['rid' => 'id']);
    }

}
